<div class="fsh-pop">
    <div id="add_form" class="layui-form">
        <input name="major_id" type="hidden" value="<%=major_id%>">
        <input name="hash" type="hidden" value="<%=hash%>">
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="required" placeholder="请输入内容" class="layui-input"
                       value="<%=title%>">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>父级分类</label>
            <div class="layui-input-block">
                <input lay-verify="required" autocomplete="off" placeholder="请选择父级分类"
                       class="layui-input" id="parent_title" value="<%=parentTitle%>">
                <input name="parent_id" type="hidden" id="parent_id" value="<%=parent_id%>">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">是否必修课</label>
            <div class="layui-input-block">
                <input type="checkbox" lay-skin="switch" lay-text="ON|OFF" lay-filter="switchTest" value="<%=subject%>"
                       id="switch">
                <input name="subject" type="hidden" id="subject" value="<%=subject%>">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input name="sort" placeholder="0" class="layui-input" type="number" value="<%=sort%>">
            </div>
        </div>


    </div>
</div>

<script>

    if ($('#subject').val() == 1) {
        $('#switch').prop('checked', true);
    }
    //监听指定开关
    layui.form.on('switch(switchTest)', function (data) {
        $("#subject").val(this.checked ? 1 : 0);
    });
    var parentId ='';
    $("#parent_title").click(function () {
        showDialog({
            title: '选择父级菜单'
            , template: 'views/category/template/menu.html'
            , width: 400
            , height: 600
            , yes: function (index, layero) {
                var res = callbackdata();
                layer.close(index);
                parentId = res.key;
                $("#parent_title").val(res.title);
                $("#parent_id").val(parentId);

            }

        });

    });
</script>
